<?php
    class model_support extends database_mysql
    {
        /*
         * mdc_cart_total_list
         * mdc_cart_list
         * */
        public function mds_support_total_list()
        {
            $tb_support = prefix . "supports";
            $sql = "SELECT COUNT(ID) as tt FROM `$tb_support` WHERE `Status`= 'true' ";
            $row = parent::mysql_fetch_one_rows($sql);
            parent::mysql_close_connection();
            $total = $row["tt"];
            return $total;
        }

        public function mds_support_list($cid = null , $page = 1 , $limit = 50)
        {
            $tb_support = prefix . "supports";
            $sql = "SELECT  * FROM `$tb_support` ORDER BY `Order` ASC";
            $row = parent::mysql_fetch_all_rows($sql);
            parent::mysql_close_connection();
            return $row;
        }

        public function mds_support_GetOneRow($ID)
        {
            $tb_support = prefix . "supports";
            $sql = "SELECT  * FROM `$tb_support` WHERE `ID`= '$ID' ";
            $row = parent::mysql_fetch_one_rows($sql);
            parent::mysql_close_connection();
            return $row;
        }
        public function mds_support_delete($ID)
        {
            $tb_support = prefix . "supports";
            $sql = "DELETE FROM `$tb_support` WHERE `ID`='$ID'";
            $row = parent::mysql_update_insert($sql);
            parent::mysql_close_connection();
            return $row;
        }

        public function mds_support_add($arr)
        {
            $tb = prefix . "supports";
            $data = array(
                'Fullname' => isset($_POST['Fullname']) && !empty($_POST['Fullname']) ? $_POST['Fullname'] : "" ,
                'Nick' => isset($_POST['nick']) && !empty($_POST['nick']) ? $_POST['nick'] : "" ,
                'Kind' => isset($_POST['Kind']) && !empty($_POST['Kind']) ? $_POST['Kind'] : "" ,
                'Order' => isset($_POST['Order']) && !empty($_POST['Order']) ? $_POST['Order'] : "" ,
                'Mobile' => isset($_POST['Mobile']) && !empty($_POST['Mobile']) ? $_POST['Mobile'] : "" ,
                'Status' => isset($_POST['Status']) && !empty($_POST['Status']) ? $_POST['Status'] : "" ,
            );

            parent::mysql_insert_array($tb , $data);
            $id = mysql_insert_id();
            parent::mysql_close_connection();
            return $id;
        }

        public function mds_support_update($arr , $ID)
        {
            $tb = prefix . "supports";
            $Fullname = isset($_POST['Fullname']) && !empty($_POST['Fullname']) ?parent::mysql_check_string($_POST['Fullname']) : "";
            $Nick = isset($_POST['nick']) && !empty($_POST['nick']) ? parent::mysql_check_string($_POST['nick']) : "";
            $Kind = isset($_POST['Kind']) && !empty($_POST['Kind']) ?parent::mysql_check_string($_POST['Kind']) : "";
            $Order = isset($_POST['Order']) && !empty($_POST['Order']) ?parent::mysql_check_string($_POST['Order']) : "";
            $Mobile = isset($_POST['Mobile']) && !empty($_POST['Mobile']) ?parent::mysql_check_string($_POST['Mobile']) : "";
            $Status = isset($_POST['Status']) && !empty($_POST['Status']) ? parent::mysql_check_string($_POST['Status']) : "false";
            $sql = "UPDATE `$tb` SET
                        `Fullname`='$Fullname' ,
                        `Nick`='$Nick' ,
                        `Kind`='$Kind' ,
                        `Order`='$Order' ,
                        `Mobile`='$Mobile',
                        `Status`='$Status'
                        WHERE  `ID` = '$ID' ";
            parent::mysql_update_insert($sql);
            parent::mysql_close_connection();
            return $sql;
        }

        public function mds_support_order($id ,$order)
        {
            $tb = prefix . "supports";
            $id = isset($id) ?parent::mysql_check_string($id) : 1;
            $order = isset($order) ?parent::mysql_check_string($order) : 1;
            $sql = "UPDATE `$tb` SET
                        `Order`='$order'
                        WHERE  `ID` = '$id' ";
            parent::mysql_update_insert($sql);
            parent::mysql_close_connection();
            return $sql;
        }

    }

